import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-05-25
 * Time: 22:01
 */
public class Main {
    public static int gcdVars(int numList){
        Scanner scanner=new Scanner(System.in);

        int[] arr=new int[numList];
        System.out.println("请输入5个整数：");
        for (int i = 0; i < numList; i++) {
            arr[i]=scanner.nextInt();
        }
        Arrays.sort(arr);
        do{

            int tmp=arr[numList-1]-arr[numList-2];
            if(tmp>arr[numList-2]){
                arr[numList-1]=tmp;
            }else{
                arr[numList-1]=arr[numList-2];
                arr[numList-2]=tmp;
            }
            Arrays.sort(arr);
        }while(arr[numList-2]!=0);
        return arr[numList-1];
    }
    public static void main(String[] args) {
        //最大公约数
        System.out.println("请输入您输入整数的数量：");
        Scanner scanner=new Scanner(System.in);
        int num=scanner.nextInt();
        System.out.println("这些数的最大公约数是："+gcdVars(num));


    }
}